/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package com.gxuwz.byssxsys.dao;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.gxuwz.byssxsys.model.*;
import com.gxuwz.byssxsys.dao.*;
import com.gxuwz.byssxsys.service.*;
import com.gxuwz.byssxsys.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

@Repository
public class SelectedSubjectsDao extends BaseHibernateDao<SelectedSubjects,java.lang.Integer>{

	public Class getEntityClass() {
		return SelectedSubjects.class;
	}
	
	public Page findPage(SelectedSubjectsQuery query) {
        //XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接 
        // [column] 为PageRequest的属性
		String sql = "select t from SelectedSubjects t where 1=1 "
			  	+ "/~ and t.ssno1 = {ssno1} ~/"
			  	+ "/~ and t.ssname2 = {ssname2} ~/"
			  	+ "/~ and t.ssrequire3 = {ssrequire3} ~/"
			  	+ "/~ and t.ssworkload4 = {ssworkload4} ~/"
			  	+ "/~ and t.sslimitMajor5 = {sslimitMajor5} ~/"
			  	+ "/~ and t.ssdifficulty6 = {ssdifficulty6} ~/"
			  	+ "/~ and t.ssremark7 = {ssremark7} ~/"
			  	+ "/~ and t.ssteacher8 = {ssteacher8} ~/"
				+ "/~ and t.sssetData9 >= {sssetData9Begin} ~/"
				+ "/~ and t.sssetData9 <= {sssetData9End} ~/"
				+ "/~ order by [sortColumns] ~/";

        //生成sql2的原因是为了不喜欢使用xsqlbuilder的同学，请修改生成器模板，删除本段的生成
        StringBuilder sql2 = new StringBuilder("select t from SelectedSubjects t where 1=1 ");
        if(isNotEmpty(query.getId())) {
            sql2.append(" and  t.id = :id ");
        }
        if(isNotEmpty(query.getSsno1())) {
            sql2.append(" and  t.ssno1 = :ssno1 ");
        }
        if(isNotEmpty(query.getSsname2())) {
            sql2.append(" and  t.ssname2 = :ssname2 ");
        }
        if(isNotEmpty(query.getSsrequire3())) {
            sql2.append(" and  t.ssrequire3 = :ssrequire3 ");
        }
        if(isNotEmpty(query.getSsworkload4())) {
            sql2.append(" and  t.ssworkload4 = :ssworkload4 ");
        }
        if(isNotEmpty(query.getSslimitMajor5())) {
            sql2.append(" and  t.sslimitMajor5 = :sslimitMajor5 ");
        }
        if(isNotEmpty(query.getSsdifficulty6())) {
            sql2.append(" and  t.ssdifficulty6 = :ssdifficulty6 ");
        }
        if(isNotEmpty(query.getSsremark7())) {
            sql2.append(" and  t.ssremark7 = :ssremark7 ");
        }
        if(isNotEmpty(query.getSsteacher8())) {
            sql2.append(" and  t.ssteacher8 = :ssteacher8 ");
        }
        if(isNotEmpty(query.getSssetData9Begin())) {
            sql2.append(" and  t.sssetData9 >= :sssetData9Begin ");
        }
        if(isNotEmpty(query.getSssetData9End())) {
            sql2.append(" and  t.sssetData9 <= :sssetData9End ");
        }
        if(isNotEmpty(query.getSortColumns())) {
            sql2.append(" order by :sortColumns ");
        }	
        
		return pageQuery(sql,query);
	}
	
	public SelectedSubjects getBySsno1(java.lang.String v) {
		return (SelectedSubjects) findByProperty("ssno1",v);
	}	

}
